package com.szxb.facebus.util.view;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.widget.FrameLayout;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

/**
 * 作者：Tangren on 2018-12-21
 * 包名：com.szxb.facebus.util.view
 * 邮箱：996489865@qq.com
 * TODO:一句话描述
 */
public class CircleLayout extends FrameLayout {
    private Paint mPaint;

    public CircleLayout(@NonNull Context context) {
        super(context, null);
    }

    public CircleLayout(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        setWillNotDraw(false);
        mPaint = new Paint();
    }


    @Override
    protected void onDraw(Canvas canvas) {
        int width = getMeasuredWidth();
        mPaint.setAntiAlias(true);
        float cirX = width / 2;
        float cirY = width / 2;
        float radius = width / 2;
        canvas.drawCircle(cirX, cirY, radius, mPaint);
        super.onDraw(canvas);
    }

}
